<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .router-link-active {
      background-color: tomato;
    }
  </style>
</head>

<body>
  <div id="app">
    <router-view></router-view>
    <router-view name="b"></router-view>
    <router-view name="c"></router-view>
  </div>
  <script src="./vue.js"></script>
  <script src="./vue-router.js"></script>
  <script>
    // home news about
    const Home = {
      template: `
        <div>
          <h1>home页</h1>
        </div>
      `
    }
    const Home2 = {
      template: `
        <div>
          <h1>home2页</h1>
        </div>
      `
    }
    const Home3 = {
      template: `
        <div>
          <h1>home3页</h1>
        </div>
      `
    }
    const routes = [ // 定义路由 规则 有哪些路由，这个路由对于的组件是什么
      {
        path: '/',
        redirect: '/home' // 重定向
      },
      {
        path: "/home",
        components: {
          default: Home,
          b: Home2,
          c: Home3
        }

      }
    ]
    // 定义路由对象
    const router = new VueRouter({
      routes
    })
    const vm = new Vue({
      el: "#app",
      router
    })
  </script>
</body>

</html>
